home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 26 / AACD 26.iso / AACD / Graphics / sKulpt / skulpt-src / win-src / 3DWProc.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-04  |  3.1 KB  |  131 lines

  1. #define STRICT
  2.  
  3. // Includes standard Windows
  4. #include <windows.h>
  5. #include <windowsx.h>
  6. #include <time.h>
  7. #include <stdlib.h>
  8. #include <malloc.h>
  9. #include <memory.h>
  10. #include <stdio.h>
  11.  
  12. // Includes D3D
  13. #define  D3D_OVERLOADS
  14. #include <ddraw.h>
  15. #include <d3d.h>
  16.  
  17. // Includes utilitaires D3D
  18. #include "d3dmath.h"
  19. #include "d3dutil.h"
  20. #include "D3DEnum.h"
  21.  
  22. #include <d3dx.h>
  23.  
  24. // Ids Resources
  25. #include "resource.h"
  26.  
  27. // Constantes
  28. #include "const.h"
  29.  
  30. // Types
  31. #include "types.h"
  32.  
  33. // Variables globales projet
  34. #include "vars.h"
  35.  
  36. // Prototypes fonctions autres modules
  37. #include "proto.h"
  38.  
  39. // Macros
  40. #include "macros.h"
  41.  
  42. void vForce3DRefresh(BOOL bFull)
  43. {
  44.     if (bFull == XDC_MODE_COMPLET)
  45.         hrRender3DEnvironment();
  46.     else
  47.         hrShowFrame();
  48. }
  49.  
  50. LRESULT CALLBACK lrPerspWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  51. {
  52.     switch( uMsg )
  53.     {
  54.         case WM_PAINT:
  55.             // If we get WM_PAINT messages, it usually means our window was
  56.             // covered up, so we need to refresh it by re-showing the contents
  57.             // of the current frame.
  58.             vForce3DRefresh(XDC_MODE_PARTIEL);
  59.             break;
  60.  
  61.         case WM_MOVE:
  62.             // Move messages need to be tracked to update the screen rects
  63.             // used for blitting the backbuffer to the primary.
  64.             if( bActive && bReady )
  65.                 vOnMove( (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam) );
  66.             break;
  67.  
  68.         case WM_SIZE:
  69.             // Check to see if we are losing or gaining our window. Set the
  70.             // active flag to match.
  71.             if( SIZE_MAXHIDE==wParam || SIZE_MINIMIZED==wParam )
  72.                 bActive = FALSE;
  73.             else bActive = TRUE;
  74.  
  75.             // A new window size will require a new backbuffer size. The
  76.             // easiest way to achieve this is to release and re-create
  77.             // everything.
  78.             if( bActive && bReady )
  79.             {
  80.                 bReady = FALSE;
  81.                 if( FAILED( hrCloseD3D(FALSE) ) )
  82.                     DestroyWindow( hWnd );
  83.  
  84.                 if( FAILED( hrInitD3D( hWnd, &gDeviceGUID ) ) )
  85.                     DestroyWindow( hWnd );
  86.  
  87.                 if (FAILED(hrInitWorld( lpd3dDevice )))
  88.                 {
  89.                     hrCloseD3D(TRUE);
  90.                     DestroyWindow( hWnd );
  91.                 }
  92.  
  93.                 // Mettre à jour les variables d'état du pipe D3D
  94.                 vSetD3DState();
  95.  
  96.                 // Remettre en service les lampes
  97.                 for (int iCnt = 0 ; iCnt <= iLampLastUsed ; iCnt++)
  98.                     if (Lampes[iCnt].bEnabled)
  99.                         bUpdateLamp(iCnt);
  100.  
  101.                 // Redessiner la scène
  102.                 vForce3DRefresh(XDC_MODE_COMPLET);
  103.  
  104.                 bReady = TRUE;
  105.             }
  106.             break;
  107.  
  108.         case WM_CHAR : //************************* F R A P P E  C L A V I E R ********************
  109.             PostMessage(hWndMenu, uMsg, wParam, lParam);
  110.             break;
  111.  
  112.         case WM_GETMINMAXINFO:
  113.             // Prevent the window from going smaller than some minimum size
  114.             ((MINMAXINFO*)lParam)->ptMinTrackSize.x = 100;
  115.             ((MINMAXINFO*)lParam)->ptMinTrackSize.y = 100;
  116.             break;
  117.  
  118.         case WM_NCLBUTTONDBLCLK :
  119.             ShowWindow(hWnd, SW_MAXIMIZE);
  120.             break;
  121.  
  122.         // case WM_CLOSE:    // (ne devrait jamais survenir : pas de close gadget)
  123.         case WM_DESTROY:
  124. //            hrCloseD3D(TRUE);
  125. //            PostQuitMessage(0);
  126.             return 0L;
  127.     }
  128.     return DefWindowProc( hWnd, uMsg, wParam, lParam );
  129. }
  130.  
  131.